#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>

#include <QMessageBox>
#include <QTimer>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    int led1_starus;
    int led2_starus;
    int led3_starus;

    double  humi_val; //湿度 现在值
    double  humi_val_dwon_val;
    double  humi_val_up_val;

    double  temp_val; //温度 现在值
    double  temp_val_dwon_val;
    double  temp_val_up_val;

    int ap3216_ir;  //人体红外
    int ap3216_als; //环境光
    int ap3216_ps;  //接近

    int led_fd;
    int si7006_fd;
    int ap3216_fd;
    char led_status_buf[3];
    int ap3216val[3];

    QTimer *timer;

    Widget(QWidget *parent = nullptr);
    ~Widget();

    int get_env_status();
    int update_env_status();
    void led_state(int ledfd,int witch,int lednum,int state);

private slots:
    void on_LED1_clicked();

    void on_LED2_clicked();

    void on_LED3_clicked();

    void timer_out_handle();

private:
    Ui::Widget *ui;
};
#endif // WIDGET_H
